import React from 'react';
import { Select } from 'antd';
import {options} from '@/services/Budget';

class OrganizationSelect extends React.Component {
  constructor (props) {
    super(props);
    this.state={
      list: []
    }
  }

  async componentDidMount () {
    const unitId = this.props.id;
    const res = await options(unitId);
    this.setState({list: res})
  }

  render () {
    const props = this.props;
    const list = this.state.list;
    return (
      <Select placeholder="请选择所属预算" {...props}>
        {list.map((item) => (
          <Select.Option value={item.key} key={item.key}>{item.value}</Select.Option>
        ))}
      </Select>
    )
  }
}

export default OrganizationSelect